Coding of residual data in predictive compression

ABSTRACT

Encoding input data includes: generating a first block of coefficients based on a transform performed on a residual block of data for multiple pixels; generating reference information based on a reference block of data corresponding to the residual block of data; and determining losslessly decodable code values representing the first block of coefficients based on the reference information.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. application Ser. No.13/334,345, filed on Dec. 22, 2011, which claims priority to U.S.Application Ser. No. 61/429,631, filed on Jan. 4, 2011, incorporatedherein by reference.

FIELD

The present application generally relates to coding and decoding mediadata (e.g., video and image coding and decoding), and in particular totechniques for coding of residual data in predictive compression.

BACKGROUND

Some standards for encoding and decoding videos (e.g., ITU-T H.264/AVCvideo coding standard) use block-based coding processes. In theseprocesses, to compress a video sequence, which consists of severalframes of pictures, a frame is divided into blocks (e.g., 4×4, 8×8,16×16, 32×32, or 64×64 blocks of pixel data). In this way, the task ofcoding the whole video sequence is broken down into coding each block,where blocks within a frame are coded in a certain order (e.g., rasterorder). The process of coding a block includes performing a transform(e.g., the discrete cosine transform (DCT)). In many cases, the databeing transformed is not the actual pixel data, but is residual datafollowing a prediction operation. For example, to code a particularblock of pixels (called the “current block”), a prediction of the samesize (called the “reference block”) is derived based on reconstructionof a block that was already coded according to the coding order. Thereference block can come from a different frame (called “interprediction”) or the same frame (called “intra prediction”). A residualblock is obtained by subtracting the reference block from current block.Each residual block is transformed into a block of transformcoefficients, the transform coefficients are optionally quantized, andthe (possibly quantized) transform coefficients are entropy encoded,yielding a bitstream. Decoding is performed using an inverse procedureincluding entropy decoding the bitstream, and de-quantizing and inversetransforming to recover the residual block. The reference block that wasused to generate the residual block at the encoder can also be recoveredat the decoder using previously decoded data. Then the current block isreconstructed by adding the residual block to the reference block.

The overall encoding/decoding procedure may result in lossycompression/decompression of the video data (e.g., if quantization isinvolved), however, the entropy encoding/decoding portion of the overallprocedure is lossless. In the AVC standard, two entropy coding methodsare employed in the block-wise prediction coding architecture describedabove: one is called context-adaptive binary arithmetic coding (CABAC)and the other one is called context-adaptive variable length coding(CAVLC).

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram of an exemplary communication system.

FIG. 2A is a block diagram of an exemplary video encoder.

FIG. 2B is a block diagram of an exemplary video decoder.

FIG. 3A is a schematic diagram of an exemplary encoding procedure.

FIG. 3B is a schematic diagram of an exemplary decoding procedure.

FIG. 4A is a flowchart of an exemplary encoding procedure.

FIG. 4B is a flowchart of an exemplary decoding procedure.

FIG. 5A is a block diagram of an exemplary encoder apparatus.

FIG. 5B is a block diagram of an exemplary decoder apparatus.

DESCRIPTION

The term “comprising” and variations thereof as used herein are usedsynonymously with the term “including” and variations thereof and areopen, non-limiting terms.

FIG. 1 shows an exemplary system 100 for communicating data, includingimage, video, or other media data, between one or more nodes 101, 102a-102 e connected over a network 104. In this example, a node 101receives a sequence of frames 106 from one or more sources (not shown)such as a video camera or a video stored in a storage medium, or anyother source that can detect, derive, capture, store or record visualinformation such as video or images. In some implementations, thesources may be in communication with the node 101, or may be a part ofthe node 101. The node 101 includes an encoder module 108 that encodesthe frames 106 to generate a stream or file of encoded video data. Inthis example, the encoded video data is provided to a node 102 a coupledto the network 104. Alternatively, the node 101 may itself be coupled tothe network 104, or the encoded video data may also or alternatively bestored locally for later transmission or output, such as in anon-volatile memory or other storage medium.

The node 102 a transmits the encoded video data (e.g., as a stream or afile) to any of a variety of other nodes 102 b-102 e (e.g., a mobiledevice, a television, a computer, etc.) coupled to the network 104. Thenode 102 a can include a transmitter configured to optionally performadditional encoding (e.g., channel coding such as forwarderror-correction coding) and to modulate the data onto signals to betransmitted over the network 104. The node 102 b receives anddemodulates the signals from the network 104 to recover the encodedvideo data. The node 102 b includes a decoder module 110 that decodesthe encoded video data and generates a sequence of reconstructed frames112. In some implementations, the node 102 b may include a display forrendering the reconstructed frames 112. The node 102 b may include astorage medium to store the encoded video data for later decodingincluding at a time when the node 102 b is not coupled to the network104.

The network 104 may include any number of networks interconnected witheach other. The network 104 may include any type and/or form ofnetwork(s) including any of the following: a wide area network (such asthe Internet), a local area network, a telecommunications network, adata communication network, a computer network, a wireless network, awireline network, a point-to-point network, and a broadcast network. Thenetwork may include any number of repeaters, appliances, devices,servers, storage media and queues.

In the description that follows, example embodiments are described withreference to two-dimensional video coding/decoding, however, thetechniques may also be applicable to image coding/decoding, videocoding/decoding that includes additional views or dimensions, includingmultiview video coding (MVC) and three-dimensional (3D) video,extensions of video coding/decoding schemes such as scalable videocoding (SVC), and other media coding/decoding schemes that use entropycoding/decoding with different contexts associated with differentportions of the data. For example, for any type of residual datapredicted from reference data, the techniques for determining areference data dependent context for entropy coding/decoding of aportion of the residual data can be applied for a variety of differentuses of the context in the entropy coding process.

In the description that follows, the terms frame and slice are usedsomewhat interchangeably. For example, in the case of the H.264standard, a frame may contain one or more slices. It will also beappreciated that certain encoding/decoding operations are performed on aframe-by-frame basis and some are performed on a slice-by-slice basis,depending on the particular requirements of the applicable video codingstandard. In any particular embodiment, the applicable video codingstandard may determine whether the operations described below areperformed in connection with frames and/or slices, as the case may be.

Reference is now made to FIG. 2A, which shows a block diagram of anencoder 200 for encoding video. Reference is also made to FIG. 2B, whichshows a block diagram of a decoder 250 for decoding video. It will beappreciated that the encoder 200 and decoder 250 described herein mayeach be implemented on an application-specific or general purposecomputing device, containing one or more processing elements and memory.The operations performed by the encoder 200 or decoder 250, as the casemay be, may be implemented by way of application-specific integratedcircuit, for example, or by way of stored program instructionsexecutable by a general purpose processor. The device may includeadditional software, including, for example, an operating system forcontrolling basic device functions.

The encoder 200 receives input data 212 from a source (e.g., a videosource) and produces an encoded bitstream 214. The decoder 250 receivesthe encoded bitstream 214 (as input data for the decoder 250) andoutputs a decoded video frame 216. The encoder 200 and decoder 250 maybe configured to operate in conformance with a number of videocompression standards. For example, the encoder 200 and decoder 250 maybe H.264/AVC compliant. In other embodiments, the encoder 200 anddecoder 250 may conform to other video compression standards, includingevolutions of the H.264/AVC standard such as the High Efficiency VideoCoding (HEVC) standard.

The encoder 200 includes a transform processor 222, a quantizer 224, andan entropy encoder 226. The input data 212 includes frames of spatialdomain data where each frame is organized, for example, as blocks ofpixel data, which may further be organized as “macroblocks” or “codingunits” that are made up of multiple blocks of pixel data. The blocks ofpixel data each comprise a two-dimensional array of pixel data whereeach pixel represents a value (e.g., a luminance value that representsan overall intensity, or a chrominance value that includes colorinformation). The transform processor 222 performs a transform upon thespatial domain data. In particular, the transform processor 222 appliesa block-based transform to convert spatial domain data (in a spatialdomain with dimensions x and y) to spectral components in a transformdomain (with dimensions f_(x) and f_(y) that represent spatialfrequencies). For example, in many embodiments a discrete cosinetransform (DCT) is used. Other transforms, such as a discrete sinetransform or others may be used in some instances. The block-basedtransform is performed on a macroblock or sub-block basis, depending onthe size of the macroblocks. In the H.264 standard, for example, atypical 16×16 macroblock contains sixteen 4×4 transform blocks and theDCT process is performed on the 4×4 blocks. In some cases, the transformblocks may be 8×8, meaning there are four transform blocks permacroblock. In yet other cases, the transform blocks may be other sizes(e.g., 16×16, 32×32, or 64×64 blocks, or rectangular blocks havingdifferent numbers of pixels in the x and y dimensions in the spatialdomain, and different numbers of coefficients in the f_(x) and f_(y)dimensions in the transform domain).

Applying the block-based transform to a block of pixel data results in aset of transform domain coefficients. A “set” in this context is anordered set in which the coefficients have coefficient positions (in thetransform domain with dimensions f_(x) and f_(y)). In some instances theset of transform domain coefficients may be considered a “block” ormatrix of coefficients. In the description herein the phrases a “set oftransform domain coefficients” or a “block of transform domaincoefficients” are used interchangeably and are meant to indicate anordered set of transform domain coefficients.

The block of transform domain coefficients is quantized by the quantizer224. The quantized coefficients and associated information are thenencoded by the entropy encoder 226.

A predictor 236 provides a reference block for performing prediction bysubtracting the reference block from a current block of the input data212 being encoded. The predictor 236 includes a module to determine theappropriate coding mode, for example, whether the frame/slice beingencoded is of I, P, or B type. Intra-coded frames/slices (i.e., type I)are encoded without reference to other frames/slices. In other words,they do not employ temporal prediction. However intra-coded frames dorely upon spatial prediction within the frame/slice. That is, whenencoding a particular block the data in the block may be compared to thedata of nearby pixels within blocks already encoded for that frame/sliceto find a similar reference block. Using a difference processor 237(e.g., subtraction of respective pixel values), the pixel data of thereference block is subtracted from the pixel data of the current blockto generate a block of residual data. The transform processor 222 thenconverts the residual data into coefficients in the transform domain.H.264, for example, prescribes nine spatial prediction modes for 4×4transform blocks, and HEVC prescribes additional spatial predictionmodes. In some embodiments, multiple of the modes may be used toindependently process a block, and then rate-distortion optimization isused to select the best mode.

Motion prediction/compensation enables the encoder 200 to take advantageof temporal prediction. Accordingly, the encoder 200 has a feedback loopthat includes a de-quantizer 228, an inverse transform processor 230,and a post-processor 232. These elements mirror the decoding processimplemented by the decoder 250 to reproduce the frame/slice. A framestore 234 is used to store the reproduced frames. In this manner, themotion prediction is based on what will be the reconstructed frames atthe decoder 250 and not on the original frames, which may differ fromthe reconstructed frames due to the lossy compression involved inencoding/decoding. When performing motion prediction/compensation, thepredictor 236 uses the frames/slices stored in the frame store 234 assource frames/slices for comparison to a current frame for the purposeof identifying similar blocks. Accordingly, for blocks to which motionprediction is applied, the “source data” which the transform processor222 encodes is the residual data that comes out of the motion predictionprocess. For example, it may include information regarding the referenceframe, a spatial displacement or “motion vector,” and residual pixeldata that represents the differences (if any) between the referenceblock and the current block. Information regarding the reference frameand/or motion vector is not necessarily processed by the transformprocessor 222 and/or quantizer 224, but instead may be supplied to theentropy encoder 226 for encoding as part of the bitstream along with thequantized coefficients.

The encoder 200 also includes a reference processor 238 that aids theentropy encoder 226 in generating a bitstream 214 that is moreefficiently compressed than it would be without it. For example, in someimplementations, the reference processor 238 processes the referenceblock that was used to generate a particular residual block and providesreference information that the entropy encoder 226 uses to categorizedifferent contexts in a context model according to spectral propertiesof the reference block (e.g., in addition to a spectral position withina transform of the residual block), as described in more detail belowwith reference to FIGS. 3A and 3B. By providing multiple contexts for agiven residual block spectral position, the entropy encoding can beperformed more efficiently. For example, in the case of an arithmeticcode, the estimated probabilities provided by different contexts can beestimated more accurately by accounting for different characteristicsthat are evident from the reference block. In the case of a Huffmancode, the different sets of codewords (called “codes”) provided bydifferent contexts can be selected in a more customized way to accountfor different characteristics that are evident from the reference block.

The decoder 250 includes an entropy decoder 252, dequantizer 254,inverse transform processor 256, and post-processor 260. A frame buffer258 supplies reconstructed frames for use by a predictor 262 in applyingspatial prediction and motion compensation. The addition processor 266represents the operation of recovering the video data for a particularreconstructed block to be supplied to the post-processor 260 from apreviously decoded reference block from the predictor 262 and a decodedresidual block from the inverse transform processor 256.

The bitstream 214 is received and decoded by the entropy decoder 252 torecover the quantized coefficients. Side information may also berecovered during the entropy decoding process, some of which may besupplied to the motion compensation loop for use in motion compensation,if applicable. For example, the entropy decoder 252 may recover motionvectors and/or reference frame information for inter-coded macroblocks.In the process of performing entropy decoding, the decoder 250 also usesinformation from a reference processor 264 to provide the same referenceinformation that was used in the encoder 200, which enables the entropydecoder 252 to assign contexts in the same way as the encoder 200, forexample, to adaptively estimate the same probabilities that were used toencode symbols in the encoder in the case of arithmetic coding, or toapply the same code in the case of Huffman coding.

The quantized coefficients are then dequantized by the dequantizer 254to produce the transform domain coefficients, which are then subjectedto an inverse transform by the inverse transform processor 256 torecreate the “video data.” In some cases, such as with an intra-codedmacroblock, the recreated “video data” is the residual data for use inspatial compensation relative to a previously decoded block within theframe. The decoder 250 generates the video data from the residual dataand pixel data from a previously decoded block. In other cases, such asinter-coded macroblocks, the recreated “video data” from the inversetransform processor 256 is the residual data for use in motioncompensation relative to a reference block from a different frame.

When performing motion compensation, the predictor 262 locates areference block within the frame buffer 258 specified for a particularinter-coded macroblock. It does so based on the reference frameinformation and motion vector specified for the inter-coded macroblock.It then supplies the reference block pixel data for combination with theresidual data to arrive at the recreated video data for that macroblock.

Post-processing may then be applied to a reconstructed frame/slice, asindicated by the post-processor 260. For example, the post-processingcan include deblocking. Certain types of post-processing are optionaland in some cases the post-processor operates in a bypass mode toprovide reconstructed data without any post-processing (e.g., deblockingmay not be necessary after spatial compensation). After post-processing,the frame/slice is output as the decoded video frame 216, for examplefor display on a display device. It will be understood that the videoplayback machine, such as a computer, set-top box, DVD or Blu-Rayplayer, and/or mobile handheld device, may buffer decoded frames in amemory prior to display on an output device.

Reference is now made to FIG. 3A, which shows a schematic diagram of anexemplary encoding procedure performed by an encoder (e.g., encoder 200)that uses entropy encoding (using any of a variety of types of losslesscoding, such as arithmetic coding or Huffman coding) with contextmodeling based on information from reference blocks (e.g., from thereference processor 238) for encoding symbols generated from residualblocks. Alternatively, instead of entropy encoding, other exemplaryencoding procedures could use lossy coding of coefficients of a symbolsgenerated from residual blocks based on a corresponding referenceblocks. A sequence of frames 300 is to be encoded. In some frames, suchas frame 302, blocks of pixels are encoded based on similar referenceblocks. In this example, a current block 304 is being encoded withrespect to a reference block 306. The reference block 306 is in the sameframe 302 as the current block 304, however, in other examples, thereference block 306 may be in a different frame from the frame 302containing the current clock 304.

The encoder generates a residual block 308 by computing differencesbetween pixel values in the current block 304 and respective pixelvalues in the reference block 306. The residual block 308 has the samespatial dimensions (along the x and y axes) as the current and referenceblocks. In this example, these blocks are 4×4 blocks, so the encoderperforms 16 subtraction operations to generate the residual block 308.Other block sizes may be used, but the sizes of the current andreference blocks are generally the same (i.e., they include the sametotal number of pixels and have the same number of pixels along the xand y dimensions). Thus, in the examples below, if other block sizeswere used, the size of the residual block and corresponding blocks wouldbe different (e.g., 8×8 blocks would yield 64 pixels in the residualblock and 64 coefficients in the coefficient blocks described below).

The encoder performs a transform operation on the residual block 308 togenerate a block of transform domain coefficients. The values of thetransform coefficients are quantized (such that the values are roundedto the closest step size of a set of quantization step sizes) to yield ablock of quantized transform coefficients 310. In some implementations,the quantization step size for each coefficient is selected dynamically,using a quantizer that is able to apply different step sizes todifferent coefficients. In the transform domain, the transformcoefficients represent points along the dimensions f_(x) and f_(y)corresponding to different weights of corresponding spatial “basispatterns,” and the f_(x) and f_(y) positions of those weights can beinterpreted as spatial frequencies associated with those basis patterns.The encoder arranges the values in the block of coefficients 310 in aparticular one-dimensional ordering according to a predeterminedscanning pattern over the two dimensions of the 4×4 array ofcoefficients 310. FIG. 3A shows an exemplary zig-zag scanning order thatcan be used to generate a series of 16 coefficient values x[0], . . . ,x[15]. Thus, the position index i of a given coefficient value x[i]within the (two-dimensional) block of coefficients represents a positionin a one-dimensional ordering of the coefficients.

In order to perform entropy encoding on the coefficient values x[0], . .. , x[15], a mapper 312 maps the values onto one or more series ofsymbols. Each symbol can take on any of a predetermined set of values.For example, in some cases the symbols represent the lengths of zeroruns and the terminating nonzero values, and in some cases (when themapper 312 performs “binarization”) the symbols are binary symbols(called “bins”) that take on one of two possible values (e.g., “0” or“1”). When generating a series of bin values from coefficient valuesx[0], . . . x[i] . . . , x[15], in some cases there is a correspondencebetween bins and coefficients such that a given bin value bin[i] isrelated to a corresponding coefficient value x[i] with the same positionindex i in a predetermined manner. However, the correspondence is notnecessarily a one-to-one correspondence. For example, for some values ofi there may not be a corresponding bin value, and some bin values bin[i]may also depend on other coefficients in addition to x[i].

An entropy encoder (e.g., entropy encoder 226) then uses an encodingengine 314 to perform entropy encoding on each series of symbols. Theencoding engine 314 accepts a series of symbols from the mapper 312 andaccepts an estimated probability for each symbol from the referenceprocessor 238. The encoding engine 314 is able to encode a series ofsymbols collectively as a unique binary value in a way that isreversible, such that the original symbols can be recovered exactly fromthat binary value. An example of such an encoding engine 314 is anarithmetic coder. By using an estimate of the probability that aparticular one of the symbols will take on a particular value in thecoding process, an arithmetic coder is able to represent the entireseries of symbols with fewer bits than would be necessary to representeach symbol individually as a binary value. This compression isachieved, generally speaking, because more probable symbols correspondto shorter bit sequences within the binary value and less probablesymbols correspond to longer bit sequences within the binary value. Themore accurate the probability estimate is, the more efficient thecompression is.

The encoding engine 314 operates in cooperation with the referenceprocessor 238 to provide accurate probability estimates. At the start ofencoding (and at the start of decoding), initial probability estimatesare stored in storage locations (called “contexts”) of a context datastructure 316. The reference processor 238 retrieves a probabilityestimate p(j) stored at a location in the data structure 316 given by acontext index j. The reference processor 238 determines the contextindex j for a given bin value bin[i] corresponding to a position index ias a function of a prediction pred based on reference information andthe coefficient position i, such that the context index j=c(i, pred) hasmultiple possible values for a given value of i. Therefore, there aremultiple possible probability estimates p(j) stored for a given value ofi. In this example shown in FIG. 3A, there are four possible values of jfor each value of i. Therefore, the reference processor 238 can retrieveany one of four possible values of a previously updated probabilityestimate for a given value of i, depending on the prediction pred. Thereference information used to determine the prediction pred is based onthe reference block 306 that was used to generate the residual block 308for the current block of coefficients 310 being encoded, as described inmore detail below.

Different probability estimates stored at different context indices areseparately updated for successive residual blocks to provide moreaccurate estimates as based on past history as more residual blocks of aframe or series of frames are encoded. The encoding engine 314overwrites the previous probability estimate p(j) with an updatedprobability estimate p′(j) computed based on the current bin value beingencoded and the previous probability estimate p(j) (reflecting any pastbin values). Because the context index j depends on reference blockprediction information, the updated probability estimate also depends onreference block prediction information. The next time a particularupdated probability is used, it represents an estimated probability thatis conditioned on both information about previously coded bin values andreference information. Optionally, different values of j can be computedfor different values of other auxiliary information (e.g., the type offrame or block or bin value being encoded) by providing an offset thatis added to the context index j that depends on that auxiliaryinformation. An exemplary procedure for updating the probabilityestimates is described in more detail in Marpe et al. “Context-BasedAdaptive Binary Arithmetic Coding in the H.264/AVC Video CompressionStandard,” IEEE Transactions on Circuits and Systems for VideoTechnology, Vol. 13, No. 7, July, 2003, incorporated herein byreference. For other types of coding (e.g., lossless coding schemes suchas Huffman coding or other entropy coding schemes, or lossy codingschemes) the coding information stored at various locations in thecontext data structure 316 does not necessarily need to be updated totake into account past history of previously encoded (or decoded)symbols.

In some implementations, the encoding engine 314 can use binaryarithmetic coding (BAC) along with a binarization process performed bythe mapper 312 in which the coefficient values x[0], . . . , x[15] aremapped into multiple different series of bins, including a “significancemap” representing the non-zero coefficient values, a “last map”representing the position of the last non-zero coefficient, and aUnary/kth order Exp-Golomb binarization of absolute values of non-zerocoefficients. To code each series of bins provided by the mapper 312,the encoding engine 314 can use a binary arithmetic code to generate abitstream representing the bins, and a probability estimator to updateprobability estimates stored in the context data structure 316. Asdescribed above, each particular bin value is used by the encodingengine 314 (or a corresponding decoder) based on an a priori estimate ofthe probability of a particular bin taking on that particular value,where an adaptive arithmetic code allows this probability to beestimated on the fly. A probability estimator can be implemented as aLaplace estimator, a Kirchevsky-Trofimov estimator, or a finite-statemachine, for example. For a finite-state implementation of a probabilityestimator, the probability is quantized to be one of a finite set ofpossible values (e.g., 64 possible values) and indexed by a state s, andprobability estimation is performed based on state transitions. Thestate determines the probability estimates of the two possible symbols(in the case of binary bin values) and the next state depends on thevalue of the symbol most recently encoded (or decoded). In the followingexample, there are 64 possible states enumerated by s=0 . . . 63, eachassociated with a corresponding probability value p₀ . . . p₆₃, wherep₀=0.5, p_(s)=α p_(s−1), and α is a number close to but less than one(e.g., α≈0.95). The probability of the least probable symbol (LPS)(e.g., either “0” or “1” for a binary bin value) is p_(s) and theprobability of the most probable symbol (MPS) is 1−p_(s). In thisexample, the probability p_(s) gets closer to 0 as s gets closer to thelargest value (63), and p_(s) gets closer to 0.5 as s gets closer to thesmallest value (0). So in the state s=0, (the “equiprobable state”) thetwo possible symbol values are equally probable. Exemplary statetransition vectors to transition to a next state s (given by the valuein the vector) from a previous state s (used to index into the vector),according to the value of the most recently encoded (or decoded) symbol,are shown below.

If the most recently encoded (or decoded) symbol is the MPS, thetransition vector is NextStateMPS[s]:

{1, 2, 3, 4, 5, 6, 7, 8,

9, 10,11,12,13,14,15,16,

17,18,19,20,21,22,23,24,

25,26,27,28,29,30,31,32,

33,34,35,36,37,38,39,40,

41,42,43,44,45,46,47,48,

49,50,51,52,53,54,55,56,

57,58,59,60,61,62,62,63}

If the most recently encoded (or decoded) symbol is the LPS, thetransition vector is NextStateLPS[s]:

{0, 0, 1, 2, 2, 4, 4, 5,

6, 7, 8, 9, 9, 11,11,12,

13,13,15,15,16,16,18,18,

19,19,21,21,22,22,23,24,

24,25,26,26,27,27,28,29,

29,30,30,30,31,32,32,33,

33,33,34,34,35,35,35,36,

36,36,37,37,37,38,38,63}

So in this example, if the MPS is received, the probability estimate forreceiving the MPS again increases until the last two states (s=62 or 63)in which case the probability estimate for receiving the MPS stays thesame. If the LPS is received, the probability estimate for receiving theMPS decreases for most states except for the first and last states (s=0or 63). If the current state is the equiprobable state and the LPS isreceived, the symbol values of the MPS and LPS are interchanged,otherwise, the symbol values of the MPS and LPS stay the same for allthe other state transitions. Using a probability estimation proceduresuch as the procedure described above enables the probability estimateto depend on the values of past encoded (or decoded) symbols. Storingand updating probability estimates in different contexts (with differentcontext indices), enables the probability estimates to also depend oninformation used to determine the contexts associated with the pastsymbols. Thus, by selecting different context indices for differentvalues of selected reference information, the probability estimates canbe made to depend on the selected reference information.

In other implementations, the encoding engine 314 can use other type ofcodes (other than an arithmetic code), such as a Huffman code or avariable-length-to-variable-length code. The other types of codes alsouse different contexts associated with different symbols for encoding aseries of symbols. For example, in Huffman coding, instead of storingprobability estimates, the contexts at different context indices storeinformation for applying different codes for different symbols. Somecodes may enable more efficient encoding for a symbol having a certainvalue of the prediction pred derived from reference informationassociated with that symbol.

To take advantage of the correlation between the reference block 306 andthe residual block 308 (and the resulting bin value being encoded), theencoding engine 314 can determine coding information (e.g., theprobability estimates for arithmetic coding or the code for Huffmancoding) based in part on reference information derived from thereference block 306. Any of a variety of techniques can be used toprocess the reference block 306 (e.g., using the reference processor238) to generate reference information that is used by the encodingengine 314. For example, reference block prediction coefficients r[0], .. . , r[15] can be derived by applying the same transformation andquantization on reference block 306 that was applied to the residualblock 308. In this example, there are 16 reference block predictioncoefficients since the reference block 306 has the same number of pixels(16) as the residual block 308. The position index i associated witheach reference block prediction coefficient r[i] can be determined usingthe same zig-zag scanning order used to determine the coefficient valuesx[0], . . . , x[15]. The computed reference block predictioncoefficients r[i] can then be used in any of a variety of ways in theentropy coding (and decoding) process. In examples below, the contextindex j for a bin symbol is computed as a function of all the encodedhistory and the reference information (e.g., some function of thereference block prediction coefficients r[0], . . . , r[15]).

To encode a bin value bin[i] at a particular position index i, twodifferent examples of possible context index computations are asfollows:j=4i+min(log₂(numPredSig+1),3)j=4i+min(log₂(r[i]+1),3)where numPredSig represents the number of non-zero coefficients in r[0],. . . , r[15], and r[i] is the value of prediction coefficient at thecorresponding position index i. The bitstream resulting from theencoding process is decodable at a decoder that uses the same codinginformation stored in a corresponding context data structure using thesame procedures for determining context indices. For example, in thecase of arithmetic coding, the decoder is able to use the same initialprobability estimates and the same procedure for updating probabilityestimates since the same reference block prediction coefficients r[0], .. . , r[15] can be generated at the decoder (using the referenceprocessor 264) by performing a transform and quantization on a referenceblock recovered from encoded data received at the decoder (e.g., areference block generated by adding a different reference block to adecoded residual block).

Reference is now made to FIG. 3B, which shows a schematic diagram of anexemplary decoding procedure performed by decoder (e.g., decoder 250)that uses entropy decoding with context modelling based on informationfrom reference blocks for decoding symbols used to recover residualblocks. For example, to decode an encoded bit sequence to recover a binvalue bin[i] at a particular position index i, the reference processor264 can use the same procedure used in the encoder (by referenceprocessor 238) to determine the context for bin[i] (at the context indexj=c(i, pred)), and the coding information (e.g., estimated probabilityp(j)) associated with that context. The prediction pred is derived, forexample, from reference information from a previously decoded referenceblock 360. An entropy decoder (e.g., entropy decoder 252) uses adecoding engine 350 to perform entropy decoding on a bitstream torecover a series of symbols, for example, a series of bins. The firstbin for a particular sequence of bin values representing a residualblock to be decoded is the bin that was first encoded at the encoderbin[0]. In the case of arithmetic coding, at the start of the decodingthe initial probability estimates are the same initial probabilityestimate that were used at the encoder. After bin[i] is decoded, theprobability estimate associated with the context used is updated byusing the same probability estimation procedure as used in the encoder,where an exemplary procedure uses the finite state machine used for BACdescribed above. The decoding engine 350 is able to determine subsequentbin values bin[i] in a sequence of bin values from previously decodedbin values bin[0] . . . bin[i−1], the corresponding probability estimatep(j), and the encoded bit sequence representing the residual block beingdecoded. The decoder is able to decode subsequent sequences of binvalues bin[i] (e.g., for subsequent residual blocks) using the updatedprobability estimates.

The recovered series of symbols is then inverse mapped by a demapper 356(e.g., by performing de-binarization) to generate the coefficient valuesx[0], . . . , x[15]. The block of quantized transform coefficients 310is then recovered according to the same scanning order used at theencoder. After applying inverse quantization and an inverse transform,the residual block 308 is recovered. At the decoder, the recoveredresidual block 308 is added to the reference block 360 to yield thereconstructed block 362. In this example, the reconstructed block 362 isbeing decoded with respect to a reference block 360 in the same frame364 as the reconstructed block 362, however, in other examples, thereference block 360 may be in a different frame from the frame 364containing the reconstructed block 362 (e.g., an other previouslydecoded frame in a sequence of decoded frames 366).

In an example based on BAC, to encode the coefficients x[0], . . . ,x[15], the mapper 312 first generates multiple series of binsrepresenting different characteristics of the coefficients from whichthe coefficients can be reconstructed. For example, two of the series ofbins are: a significance map sig[0], . . . , sig[15], and a last maplast[0], . . . , last[15], where for any j, sig[j]=(x[j] !=0) andlast[j]=(j==L_(x)), where L_(x) denotes the position of the lastnon-zero coefficient in x[0], . . . , x[15]. Other series of binsinclude a “greater than one map” which indicates whether a coefficient'sabsolute value is greater than one, and various “level maps” thatindicate whether a coefficient's absolute value is greater than aparticular level. Some of the series of bins (not necessarily all ofthem) are losslessly encoded by the encoding engine 314.

An exemplary procedure that can be used by the encoding engine 314 forperforming arithmetic coding to encode the significance and last mapsusing contexts to store adaptively updated probability estimates is asfollows.

for (i=0; i < 15; i++) { assign context to estimate the probability forencoding sig[i]; if (sig[i] ==1) { assign context to estimate theprobability for encoding last[i]; terminate the encoding of thesignificance map if (i==L_(x)); } }

An exemplary procedure that can be used by the encoding engine 314 forperforming arithmetic coding to encode the “greater than one” and levelmaps of significant coefficients after the encoding of the significanceand last maps is as follows.

c1 = 1; c2=0; for (i=L_(x); i >= 0; i−−) { if (sig[i]==1) { assigncontext to encode (abs(x[i])==1); if (abs(x[i]) > 1) { c1 = 0; assigncontext to encode the level of x[i]−2; c2++; } else { if (c1 > 0) c1++;} } }

The steps of assigning a context for encoding a given value areperformed using the reference processor 238, and the steps of estimatingupdated probabilities to be associated with the assigned context areperformed using the probability estimator 316, as described above.

Additional examples of possible context index computations for thedifferent series of bin values, including offsets associated withdifferent series of bin values, are as follows.

j = ctx_sig_offset + 4i + min(log₂(r[i]+1), 3) for sig[i] j =ctx_last_offset + 4i + min(log₂(numPredSig+1), 3)) for last[i] j =ctx_greone_offset + 4min(c1,4) + min(log₂(r[i]+1), for 3) (abs(x[i])==1)j = context_level_offset + 4min(c2,4) + for level of min(log₂(r[i]+1),3) x[i]−2

The following tables show exemplary values of a quantized 4×4 transformcoefficient block generated from a particular residual block, and acorresponding prediction coefficient block generated from the referenceblock that was used to generate the particular residual block. Thefollowing example illustrates various operations in an encodingprocedure that uses some of the techniques described herein.

Coefficient Block −16 −1 0 0 −4 0 0 0 0 1 0 0 −1 1 0 0

Prediction Coefficient Block 49 0 0 0 −4 0 0 0 −1 0 0 0 −2 0 0 0

The following table shows values of the position index, the absolutevalues of the residual transform coefficients, the signs of the residualtransform coefficients, and the prediction coefficients.

Zigzag scan index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |x| 16 1 4 0 0 00 0 1 1 1 0 0 0 0 0 sign − − − + − + pred 49 0 4 1 0 0 0 0 0 2 0 0 0 0 00

The signs can be encoded separately without context probabilityestimates. Therefore, only the absolute values of the residual transformcoefficients will be considered in this example.

The following table additionally shows values of the significance mapand the last map in their corresponding index positions.

Significance and Last maps index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15|x| 16 1 4 0 0 0 0 0 1 1 1 0 0 0 0 0 pred 49 0 4 1 0 0 0 0 0 2 0 0 0 0 00 sig 1 1 1 0 0 0 0 0 1 1 1 last 0 0 0 0 0 1

Some index positions for these maps do not have corresponding values ifthose values are not needed to fully represent the information in themap. For example, only those index positions with a value of sig=1 havea last map value, since the meaning of the last map is whether thecorresponding value is the last non-zero coefficient.

To encode the significance map, the context index j for retrieving theprobability estimate p(j)=sig_p[j] is: j=4*i+min(floor(log₂(r[i]+1)),3).

To encode the last map, the context index j for retrieving theprobability estimate p(j)=last_p[j] is:j=4*i+min(floor(log₂(numPredSig+1)),3).

In this example, the number of non-zero coefficients in the predictioncoefficient block is given by numPredSig=4.

The significance and last maps can then be encoded using the followingsequence of operations, where each row represents a different value of ifor one of the maps, and includes providing the pair of values (map[i],p(j)) to an arithmetic code engine (e.g., implemented using the encodingengine 314) and updating the probability p(i):

(1,sig_p[4*0+3])→arithmetic code engine→update sig_p[4*0+3]

(0,last_p[4*0+2])→arithmetic code engine→update last_p[4*0+2]

(1,sig_p[4*1+0])→arithmetic code engine→update sig_p[4*1+0]

(0,last_p[4*1+2])→arithmetic code engine→update last_p[4*1+2]

(1,sig_p[4*2+2])→arithmetic code engine→update sig_p[4*2+2]

(0,last_p[4*2+2])→arithmetic code engine→update last_p[4*2+2]

(0,sig_p[4*3+0])→arithmetic code engine→update sig_p[4*3+0]

(0,sig_p[4*4+0])→arithmetic code engine→update sig_p[4*4+0]

(0,sig_p[4*5+0])→arithmetic code engine→update sig_p[4*5+0]

(0,sig_p[4*6+0])→arithmetic code engine→update sig_p[4*6+0]

(0,sig_p[4*7+0])→arithmetic code engine→update sig_p[4*7+0]

(1,sig_p[4*8+0])→arithmetic code engine→update sig_p[4*8+0]

(0,last_p[4*8+2])→arithmetic code engine→update last_p[4*8+2]

(1,sig_p[4*9+1])→arithmetic code engine→update sig_p[4*9+1]

(0,last_p[4*9+2])→arithmetic code engine→update last_p[4*9+2]

(1,sig_p[4*10+0])→arithmetic code engine→update sig_p[4*10+0]

(1,last_p[4*10+2])→arithmetic code engine→update last_p[4*10+2]

FIG. 4A shows a flowchart for an exemplary encoding procedure 400 forencoding input data, which may be part of a procedure performed by anencoder (e.g., encoder 200) that includes additional steps not shown.The procedure 400 includes generating (402) a first block ofcoefficients (e.g., x[0], . . . , x[15]) based on a transform performedon a residual block of data for multiple pixels. The encoder determines(404) whether symbols representing the first block of coefficients areto be encoded using different contexts for different symbols based onreference information. If so, then the encoder generates (406) referenceinformation based on a reference block of data corresponding to theresidual block of data; and determines (408) losslessly decodable codevalues representing the first block of coefficients based on thereference information. If not, then the encoder encodes (410) the firstblock of coefficients without using different contexts for differentsymbols based on reference information.

FIG. 4B shows a flowchart for an exemplary decoding procedure 450 fordecoding encoded input data including one or more code values, which maybe part of a procedure performed by an decoder (e.g., decoder 250) thatincludes additional steps not shown. The decoder determines (452)whether the code values are to be decoded into symbols for a first blockof coefficients (e.g., x[0], . . . , x[15]) using different contexts fordifferent symbols based on reference information. If so, then thedecoder generates (454) reference information (e.g., r[0], . . . ,r[15]) based on a reference block of data corresponding to a residualblock of data, and losslessly decodes (456) code values to generate afirst block of coefficients based on the reference information. If not,then the decoder decodes (458) the code values without using differentcontexts for different symbols based on reference information. Theprocedure 450 also includes generating (460) the residual block of databased on an inverse-transform performed on the first block ofcoefficients, and generating (462) a block of data for multiple pixelsin a reconstructed frame based on a sum of the reference block of dataand the residual block of data.

Reference is now made to FIG. 5A, which shows a simplified block diagramof an example embodiment of an encoder 500. The encoder 500 includes aprocessor 502, a memory 504 accessible by the processor 502, and anencoding application 506. The encoding application 506 may include acomputer program or application stored in the memory 504 and containinginstructions for configuring the processor 502 to perform steps oroperations such as those described herein. The encoding application 506may include one or more components or modules for performing variousaspects of the techniques described herein. For example, a referenceprocessor 238, as described herein, can be included as a module of theencoding application 506. The encoding application 506, or any of itsmodules, may be stored in any combination of the memory 504 of theencoder 500, and any other accessible computer readable storage medium,such as a compact disc, flash memory device, random access memory, harddrive, etc. The encoder 500 also includes a communications interface 508accessible by the processor 502 to transmit a bitstream comprisingencoded video data generated by the processor 502 executing the encodingapplication 506.

Reference is now also made to FIG. 5B, which shows a simplified blockdiagram of an example embodiment of a decoder 550. The decoder 550includes a processor 552, a memory 554, and a decoding application 556.The decoding application 556 may include a computer program orapplication stored in the memory 554 and containing instructions forconfiguring the processor 552 to perform steps or operations such asthose described herein. The decoding application 556 may include one ormore components or modules for performing various aspects of thetechniques described herein. For example, a reference processor 264, asdescribed herein, can be included as a module of the decodingapplication 556. The reference processor 264 is configured to performcomputations corresponding to those performed by the reference processor238 that was used to encode the video data that is being decoded. Forexample, the reference processor 264 adaptively updates the contextmodel including the estimated probabilities stored in the contexts forperforming arithmetic decoding, based in part on information fromreference blocks, as described herein. The decoding application 556, orany of its modules, may be stored in any combination of the memory 554of the decoder 550, and any other accessible computer readable storagemedium, such as a compact disc, flash memory device, random accessmemory, hard drive, etc. The decoder 550 also includes a communicationsinterface 560 accessible by the processor 552 to receive a bitstreamcomprising encoded video data to be decoded by the processor 552executing the decoding application 556.

The decoder and/or encoder may be implemented in a number of computingdevices, including, without limitation, servers, suitably programmedgeneral purpose computers, set-top television boxes, televisionbroadcast equipment, and mobile devices. The decoder or encoder may beimplemented by way of software containing instructions for configuring aprocessor to carry out the functions described herein. The softwareinstructions may be stored on any suitable computer-readable memory,including CDs, RAM, ROM, Flash memory, etc.

It will be understood that the encoder described herein and the module,routine, process, thread, or other software component implementing thedescribed method/process for configuring the encoder may be realizedusing standard computer programming techniques and languages. Thetechniques described herein are not limited to particular processors,computer languages, computer programming conventions, data structures,or other such implementation details. The described processes may beimplemented as a part of computer-executable code stored in volatile ornon-volatile memory, as part of an application-specific integrated chip(ASIC), etc.

In one aspect, in general, encoding input data includes: generating afirst block of coefficients based on a transform performed on a residualblock of data for multiple pixels; generating reference informationbased on a reference block of data corresponding to the residual blockof data; and determining losslessly decodable code values representingthe first block of coefficients based on the reference information.

Aspects can include one or more of the following features.

For example, determining losslessly decodable code values representingthe first block of coefficients based on the reference information mayinclude determining portions of a code value representing respectiveportions of the first block of coefficients based on at least one valuederived from at least a portion of the reference information.Determining the portions of the code value representing respectiveportions of the first block of coefficients based on at least one valuederived from at least a portion of the reference information may includedetermining the portions based on respective estimated probabilitiesestimated according to: one or more previously determined code values,and the at least one value.

The estimated probability for determining a first portion of the codevalue is based on a value stored in a data structure at a locationidentified by an index that depends on: a position within the firstblock of coefficients, and the at least one value. The position withinthe first block of coefficients comprises a position in aone-dimensional ordering of the coefficients in the first block ofcoefficients. A value stored at a first location in the data structuremay be updated based on: a value previously stored at the first locationassociated with the one or more previously determined code values, and avalue of a symbol representing a portion of the first block ofcoefficients. The estimated probability for determining a first portionof the code value may include a conditional probability that a symbolrepresenting a portion of the first block of coefficients has aparticular symbol value given the one or more previously determined codevalues and the at least one value.

The symbol representing a portion of the first block of coefficients mayinclude a binary symbol determined according to a value of a coefficientin the first block of coefficients in a particular position with respectto a transform domain of the transform performed on the residual block.The reference information based on the reference block of data mayinclude a second block of coefficients based on a transform performed onthe reference block of data. The at least one value according to which aparticular probability is being estimated may include a value based on acoefficient in the second block of coefficients that has a positionwithin the second block of coefficients that corresponds to a positionof a coefficient within the first block of coefficients for which theparticular probability is being estimated.

The at least one value may include a value based on a number of non-zerocoefficients in the second block of coefficients. Generating the firstblock of coefficients based on a transform performed on the residualblock may include quantizing values resulting from the transform.Generating the second block of coefficients based on a transformperformed on the reference block of data may include quantizing valuesresulting from the transform. The respective portions of the first blockof coefficients may include a series of symbols, with each symbol havinga value determined by at least one coefficient of the first block ofcoefficients.

The symbols are binary symbols each having one of two possible values.The respective portions of the first block of coefficients may include aseries of symbols, with each symbol having a value determined by atleast one coefficient of the first block of coefficients. The code valuerepresenting the respective portions of the first block of coefficientsmay include an arithmetic code value generated based on the series ofsymbols and the respective estimated probabilities. Each of the seriesof symbols has a symbol value that is associated with a correspondingone of the respective estimated probabilities. A set of codewords forlosslessly decoding at least one of the code values is based oninformation stored in a data structure at a location identified by anindex that depends on: a position within the first block ofcoefficients, and the at least one value.

The position within the first block of coefficients includes a positionin a one-dimensional ordering of the coefficients in the first block ofcoefficients. The losslessly decodable code values are determined usinga coding scheme selected from the group consisting of: arithmeticcoding, and Huffman coding.

In another aspect, in general, decoding encoded input data including oneor more code values includes: generating reference information based ona reference block of data corresponding to a residual block of data;losslessly decoding code values to generate a first block ofcoefficients based on the reference information; generating the residualblock of data based on an inverse-transform performed on the first blockof coefficients; and generating a block of data for multiple pixels in areconstructed frame based on a sum of the reference block of data andthe residual block of data.

Aspects can include one or more of the following features. For example,losslessly decoding code values to generate a first block ofcoefficients based on the reference information may include determiningportions of a first block of coefficients based on respective portionsof a received code value and at least one value derived from at least aportion of the reference information. Determining the portions of thefirst block of coefficients based on respective portions of a receivedcode value and at least one value derived from at least a portion of thereference information may include determining the portions based onrespective estimated probabilities estimated according to: one or morepreviously decoded code values, and the at least one value.

The estimated probability for determining a first portion of the firstblock of coefficients is based on a value stored in a data structure ata location identified by an index that depends on: a position within thefirst block of coefficients, and the at least one value. The positionwithin the first block of coefficients may include a position in aone-dimensional ordering of the coefficients in the first block ofcoefficients.

A value stored at a first location in the data structure may be updatedbased on: a value previously stored at the first location associatedwith the one or more previously decoded code values, and a value of asymbol representing the first portion of the first block ofcoefficients. The estimated probability for determining a first portionof the first block of coefficients comprises a conditional probabilitythat a symbol representing the first portion of the first block ofcoefficients has a particular symbol value given the one or morepreviously decoded code values and the at least one value. The symbolrepresenting the first portion of the first block of coefficients mayinclude a binary symbol determined according to a value of a coefficientin the first block of coefficients in a particular position with respectto a transform domain of the first block of coefficients. The referenceinformation may be based on the reference block of data comprises asecond block of coefficients based on a transform performed on thereference block of data. The at least one value according to which aparticular probability is being estimated may include a value based on acoefficient in the second block of coefficients that has a positionwithin the second block of coefficients that corresponds to a positionof a coefficient within the first block of coefficients for which theparticular probability is being estimated.

The at least one value may include a value based on a number of non-zerocoefficients in the second block of coefficients. A set of codewords forlosslessly decoding at least one of the code values is based oninformation stored in a data structure at a location identified by anindex that depends on: a position within the first block ofcoefficients, and the at least one value. The position within the firstblock of coefficients may include a position in a one-dimensionalordering of the coefficients in the first block of coefficients.

The code values are decoded using a coding scheme selected from thegroup consisting of: arithmetic coding, and Huffman coding.

Aspects can have one or more of the following advantages.

Before the entropy encoding process, the quantized transformcoefficients are represented as a series of symbols (e.g., binarysymbols). A context model enables a current symbol to be encodedaccording to a probability estimated based on contextual informationderived from previously encoded video data. The contextual informationcan be stored in a number of contexts (e.g., each context can correspondto a different storage location in a data structure). In order toachieve high compression efficiency in the entropy encoding, it ishelpful to use a large amount of contextual information to estimate theprobability. However, when the number of contexts is large in comparisonto available data, a potential problem called “context dilution” maysignificantly degrade the compression efficiency. Context dilution mayresult, for example, from avoiding a probability estimate of zero insome coding techniques. In a typical case of video compression, thequantized transform coefficients may vary greatly in size and range,posing potential challenges in designing an efficient context model. Thetechniques described herein facilitate balancing the number of contextsand the compression efficiency.

Other features and advantages of the invention are apparent from thepresent description, and from the claims.

Certain adaptations and modifications of the described embodiments canbe made. Therefore, the above discussed embodiments are considered to beillustrative and not restrictive.

What is claimed is:
 1. A method for encoding input data, the methodcomprising: generating a first block of coefficients based on atransform performed on a residual block of data for multiple pixels;generating reference information based on a reference block of datacorresponding to the residual block of data; and computing losslesslydecodable code values representing the first block of coefficients basedon the reference information, wherein computing losslessly decodablecode values comprises determining portions of a code value representingrespective portions of the first block of coefficients based on at leastone value derived from at least a portion of the reference information,and wherein determining the portions of the code value comprisesdetermining the portions based on respective estimated probabilities orcodes determined according to the at least one value.
 2. The method ofclaim 1, wherein the estimated probabilities determined according to theat least one value are also determined according to one or morepreviously decoded code values.
 3. The method of claim 2, wherein theestimated probability for determining a first portion of the code valueis based on a value stored in a data structure at a location identifiedby an index that depends on: a position within the first block ofcoefficients, and the at least one value.
 4. The method of claim 3,wherein the position within the first block of coefficients comprises aposition in a one-dimensional ordering of the coefficients in the firstblock of coefficients.
 5. The method of claim 3, further comprisingupdating a value stored at a first location in the data structure basedon: a value previously stored at the first location associated with theone or more previously decoded code values, and a value of a symbolrepresenting a portion of the first block of coefficients.
 6. The methodof claim 2, wherein the estimated probability for determining a firstportion of the code value comprises a conditional probability that asymbol representing a portion of the first block of coefficients has aparticular symbol value given the one or more previously decoded codevalues and the at least one value.
 7. The method of claim 6, wherein thesymbol representing a portion of the first block of coefficientscomprises a binary symbol determined according to a value of acoefficient in the first block of coefficients in a particular positionwith respect to a transform domain of the transform performed on theresidual block.
 8. The method of claim 1, wherein the referenceinformation based on the reference block of data comprises a secondblock of coefficients based on a transform performed on the referenceblock of data.
 9. The method of claim 8, wherein the at least one valueaccording to which a particular probability is being estimated comprisesa value based on a coefficient in the second block of coefficients thathas a position within the second block of coefficients that correspondsto a position of a coefficient within the first block of coefficientsfor which the particular probability is being estimated.
 10. The methodof claim 8, wherein the at least one value comprises a value based on anumber of non-zero coefficients in the second block of coefficients. 11.The method of claim 8, wherein generating the second block ofcoefficients based on a transform performed on the reference block ofdata comprises quantizing values resulting from the transform.
 12. Themethod of claim 1, wherein generating the first block of coefficientsbased on a transform performed on the residual block comprisesquantizing values resulting from the transform.
 13. The method of claim1, wherein the respective portions of the first block of coefficientscomprise a series of symbols, with each symbol having a value determinedby at least one coefficient of the first block of coefficients.
 14. Themethod of claim 13, wherein the symbols are binary symbols each havingone of two possible values.
 15. The method of claim 1, wherein therespective portions of the first block of coefficients comprise a seriesof symbols, with each symbol having a value determined by at least onecoefficient of the first block of coefficients.
 16. The method of claim15, wherein the code value representing the respective portions of thefirst block of coefficients comprises an arithmetic code value generatedbased on the series of symbols and the respective estimatedprobabilities.
 17. The method of claim 15, wherein each of the series ofsymbols has a symbol value that is associated with a corresponding oneof the respective estimated probabilities.
 18. The method of claim 1,wherein a set of codewords for losslessly decoding at least one of thecode values is based on information stored in a data structure at alocation identified by an index that depends on: a position within thefirst block of coefficients, and the at least one value.
 19. The methodof claim 18, wherein the position within the first block of coefficientscomprises a position in a one-dimensional ordering of the coefficientsin the first block of coefficients.
 20. The method of claim 1, whereinthe losslessly decodable code values are computed using a coding schemeselected from the group consisting of: arithmetic coding, and Huffmancoding.
 21. A non-transitory computer readable medium storing a computerprogram for encoding input data, the computer program includinginstructions for causing a computer system to: generate a first block ofcoefficients based on a transform performed on a residual block of datafor multiple pixels; generate reference information based on a referenceblock of data corresponding to the residual block of data; and computelosslessly decodable code values representing the first block ofcoefficients based on the reference information, wherein computinglosslessly decodable code values comprises determining portions of acode value representing respective portions of the first block ofcoefficients based on at least one value derived from at least a portionof the reference information, and wherein determining the portions ofthe code value comprises determining the portions based on respectiveestimated probabilities or codes determined according to the at leastone value.
 22. An apparatus for encoding input data, the apparatuscomprising: a memory configured to buffer one or more framesreconstructed from the input data; and at least one processor coupled tothe memory and configured to process the input data based on the one ormore frames buffered in the memory, the processing including: generatinga first block of coefficients based on a transform performed on aresidual block of data for multiple pixels; generating referenceinformation based on a reference block of data corresponding to theresidual block of data; and computing losslessly decodable code valuesrepresenting the first block of coefficients based on the referenceinformation, wherein computing losslessly decodable code valuescomprises determining portions of a code value representing respectiveportions of the first block of coefficients based on at least one valuederived from at least a portion of the reference information, andwherein determining the portions of the code value comprises determiningthe portions based on respective estimated probabilities or codesdetermined according to the at least one value.